<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>招商用户管理</title>
    <link href="https://file.51kuafu.com/0c/5e/d985fdbddc027124d4e6879ce1a1860832cda85e2b517c18d8fbd2fffc06.css?bootstrap.min.css" rel="stylesheet">
    <link href="https://file.51kuafu.com/b2/2c/8ea45fe905650f8087108b5ed32c1923bcd80d400adc9b0241f18be40208.css?bootstrap-datepicker.min.css" rel="stylesheet">
    <script src="https://file.51kuafu.com/ff/15/23fb7389539c84c65aba19260648793bb4f5e29329d2ee8804bc37a3fe6e.js?jquery.min.js"></script>
    <script src="https://file.51kuafu.com/7e/02/c082fedfc821a8a51fe004dab6896dd928876a21ccac8675142c2e2f7b1f.js?bootstrap.bundle.min.js"></script>
    <script src="https://file.51kuafu.com/6e/a5/5ea86749ee1fe560fabac6b3effd81b33046fa74dc657e24d41d28110a9f.js?bootstrap-datepicker.min.js"></script>
    <script src="https://file.51kuafu.com/b4/c3/0f02638b91ebf14a458a03d143082df12dada8e0bb02a33248b5469a6df0.js?bootstrap-datepicker.zh-CN.min.js"></script>
</head>
<body>

<div class="container-fluid">
    <div class="jumbotron alert-primary">
        <h3 class="display-4"><b>销氪系统招商坐席管理</b></h3>
        <p class="lead"></p>
        <hr class="my-4">
        <p>点击最下面的“确认修改”后，才会最终生效</p>
        <a class="btn btn-warning btn-lg btn-add" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
            新增坐席
        </a>
    </div>

    <br>
    <form action="investment/saveAll" method="post">
    <table class="table  table-hover table-bordered">
        <thead class="thead-dark">
        <tr>
            <th scope="col" style="width: 7%">ID</th>
            <th scope="col" style="width: 7%">姓名</th>
            <th scope="col" style="width: 12%">线索分配指定销氪用户</th>
            <th scope="col" style="width: 8%">线索来源</th>
            <th scope="col" style="width: 8%">交互方式</th>
            <th scope="col" style="width: 8%">分配规则</th>
            <th scope="col" style="width: 7%">操作</th>
        </tr>
        </thead>
        <tbody>
        @foreach($list as $k => $item)
                <tr>
                    <th style="vertical-align: middle"  class="status">
                       {{$item->id}}
                    </th>
                    <td style="vertical-align: middle">
                        <input type="text" class="form-control sort" value="{{$item->name}}" name="name[{{$item->id}}]" required>
                    </td>
                    <td style="vertical-align: middle">
                        <input type="number" class="form-control sort" value="{{$item->xiaokeUserId}}" name="xiaokeUserId[{{$item->id}}]">
                    </td>
                    <td style="vertical-align: middle">
                        <input type="text" class="form-control sort" value="{{$item->source}}" name="source[{{$item->id}}]">
                    </td>
                    <td style="vertical-align: middle">
                        <input type="text" class="form-control sort" value="{{$item->interactiveChannel}}" name="interactiveChannel[{{$item->id}}]">
                    </td>
                    <td style="vertical-align: middle">
                        <input type="checkbox" name="public[{{$item->id}}]" {!! $item->public ? 'checked' : '' !!}> 均分公海
                        <br>
                        <input type="checkbox" name="direct[{{$item->id}}]" {!! $item->direct ? 'checked' : '' !!}> 自有线索
                    </td>
                    <td style="vertical-align: middle">
                        <button type="button" class="btn btn-danger delete">删除</button>
                    </td>
                </tr>
        @endforeach
        </tbody>
    </table>
    <button type="submit" class="btn btn-primary submitAll">确认修改</button>
    </form>
</div>
<script>
    let maxId = {{ $maxId }};
    $('.btn-add').on('click', function () {
        let num = ++maxId;
        $('tbody').append(`<tr>
                    <th style="vertical-align: middle" class="status">
                       -
                    </th>
                    <td style="vertical-align: middle">
                        <input type="text" class="form-control sort" value="" name="name[` + num + `]" required="">
                    </td>
                    <td style="vertical-align: middle">
                        <input type="number" class="form-control sort" value="" name="xiaokeUserId[` + num + `]">
                    </td>
                    <td style="vertical-align: middle">
                        <input type="text" class="form-control sort" value="" name="source[` + num + `]">
                    </td>
                    <td style="vertical-align: middle">
                        <input type="text" class="form-control sort" value="" name="interactiveChannel[` + num + `]">
                    </td>
                    <td style="vertical-align: middle">
                        <input type="checkbox" name="public[` + num + `]"> 均分公海
                        <br>
                        <input type="checkbox" name="direct[` + num + `]"> 指定专属
                    </td>
                    <td style="vertical-align: middle">
                        <button type="button" class="btn btn-danger delete">删除</button>
                    </td>
                </tr>`);
    });

    $(document).on('click', '.delete', function () {
        let that = $(this);
        that.parents('tr').remove();
    });
</script>
</body>
</html>


